package io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileCopy2 {

	public static void main(String[] args) throws Exception {
		InputStream inputStream = new FileInputStream("a.jpg");
		BufferedInputStream bin = new BufferedInputStream(inputStream);
		
		OutputStream outputStream = new FileOutputStream("sb.jpg");
		BufferedOutputStream bout = new BufferedOutputStream(outputStream);
		
		long start = System.currentTimeMillis();
		int m = 0;

		while ((m=bin.read())!=-1) {
			bout.write(m);
		}
		
		inputStream.close();
		outputStream.close();
		long end = System.currentTimeMillis();
		System.out.println(end-start+"ms");

	}
	
}
